<template>
	<div class="photoInfo-container">
		<!-- 标题 -->
		<div class="title-container">
			<h4>{{imageInfo.title}}</h4>
			<p class="subtitle">
				<span>发表时间：{{imageInfo.add_time}}</span>
				<span>点击次数:{{imageInfo.click}}</span>
			</p>
		</div>
	<!-- 缩略图 -->
		<div class="thumbs">
			 <vue-preview :slides="thumbImgs" ></vue-preview>
		</div>
	 
		<div class="content" v-html="imageInfo.content"></div>
		<!-- 评论组件 -->
		<cmt-box :artid="id"></cmt-box>

	</div>
</template>
<style  lang="scss">
	.photoInfo-container{
		padding: 2px;
		.title-container{
			h4{
				font-size: 14px;
				color:red;
				text-align: center;
			}
			p{ color:gray;
				display: flex;
				font-size: 12px;
				justify-content:space-between;
			}
		}
		.content{
			font-size: 12px;
			line-height: 30px;
		}
		// 缩略图样式
		.thumbs {
          .my-gallery{   //deep深层作用选择器
                display: flex;
                flex-wrap:wrap;//默认换行
                figure{
                    width: 30%;
                    margin: 5px;
                    img{
                        width: 100%;
                        box-shadow: 0 0 8px #999;
                        border-radius: 5px;
                    }
                }
            }
        }
	}
</style>
<script type="text/javascript">
	//导入评论子组件
	import commit from '../subComponents/commit.vue'
	export default{
		data:function(){
			return {
				id:this.$route.params.imgid,
				imageInfo:[], //图片详情数据
				thumbImgs:[]//缩略图数组
			};
		},
		methods:{
			// 获取图片详情数据
			getImageInfo(){
				this.$http.get('api/getimageInfo/'+this.id).then(resault=>{
					if(resault.body.status==0)
					{
						
						this.imageInfo = resault.body.message[0];
					}
						
					});
				
			},
			// 获取缩略图数组
			getThumbs(){
				this.$http.get('api/getthumimages/'+this.id).then(resault=>{
					if(resault.body.status==0)
					{
						
						resault.body.message.forEach( function(item,i){
							item.msrc = item.src;
							item.w=600;
							item.h=600;
							item.alt='pic'+i;
						});
						this.thumbImgs=resault.body.message;

					}
				});
			}
		},
		// 注册评论子组件
		components:{
			'cmt-box':commit
		},
		created:function(){
			this.getImageInfo();
			this.getThumbs();
		}
	}
</script>